

********************************************************************************
* Table 5: The Reaction of Bond Yields to the Long-run Dot Plot
********************************************************************************

use "../data/final_data_fed_secular_decline.dta", clear

*2-day changes in TIPS yield
generate tipsy10_2dchg = tipsy10_chg + tipsy10_chg[_n+1]
generate tips5y5y_2dchg = tips5y5y_chg + tips5y5y_chg[_n+1]

*Compute 13-week changes in some variables
generate logchg_sp500 = log(spx) - log(L91.spx)
generate logchg_bcom = log(bcom) - log(L91.bcom) - 0.4 * (log(bcomag) - log(L91.bcomag))
generate chg_slope = slope - L91.slope

*Use variables from prior to the window
local varlist "logchg_sp500 logchg_bcom chg_slope nfp_std"
foreach x of local varlist{
	*Replace missing values
	replace `x' = `x'[_n-1] if missing(`x')
	
	*Obtain value from 2 days before the meeting
	generate L2_`x' = `x'[_n-2]
	drop `x'
}

*Keep only the dot plot observations
keep if date >= mdy(1,1,2012)
keep if !missing(dotlr_chg)

*Label of the x-variables
label var dotlr_chg 			"$\Delta\mathbb{E}^F$[Long-run fed funds rate]"
label var dot1y_chg				"$\Delta\mathbb{E}^F$[1-year fed funds rate]"
label var L2_logchg_sp500		"$\Delta$ log S\&P500"
label var L2_logchg_bcom		"$\Delta$ log Yield Curve Slope (10y--3m)"
label var L2_chg_slope			"$\Delta$ log Bloomberg Commodity Index"
label var lagged_cfnai			"Chicago Fed National Activity Index"
label var lagged_bbkmleix		"Brave-Butters-Kelley Leading Index"
label var L2_nfp_std			"Nonfarm Payroll Surprise"

*Regression: 10y yield
eststo clear
quietly eststo: regress tipsy10_2dchg dotlr_chg, vce(hc3)
quietly eststo: regress tipsy10_2dchg dotlr_chg dot1y_chg, vce(hc3)
quietly eststo: regress tipsy10_2dchg dotlr_chg L2_logchg_sp500 L2_logchg_bcom L2_chg_slope, vce(hc3)
quietly eststo: regress tipsy10_2dchg dotlr_chg lagged_cfnai lagged_bbkmleix  L2_nfp_std , vce(hc3)

*Regression: 5y5y forward rate
quietly eststo: regress tips5y5y_2dchg dotlr_chg , vce(hc3)
quietly eststo: regress tips5y5y_2dchg dotlr_chg dot1y_chg , vce(hc3)
quietly eststo: regress tips5y5y_2dchg dotlr_chg L2_logchg_sp500 L2_logchg_bcom L2_chg_slope, vce(hc3)
quietly eststo: regress tips5y5y_2dchg dotlr_chg lagged_cfnai lagged_bbkmleix L2_nfp_std , vce(hc3)

esttab, r2 starlevels(* 0.10 ** 0.05 *** 0.01) se label varwidth(40) ///
	 b(%8.2f) sfmt(%8.2f %9.0fc)

esttab using "../tables/table5.tex", replace label nonotes se ///
	 mgroup("$\Delta$10y real yield" "$\Delta$5y5y real forward rate", pattern(1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	 nomtitles noconstant ///
	 noobs scalars("r2 \$R^2\$" "N N") msign($-$) ///
	 starlevels(* 0.10 ** 0.05 *** 0.01) ///
	 b(%8.2f) sfmt(%8.2f %9.0fc) ///
	 substitute(\hline \toprule) ///
	 varwidth(40) ///
	 order(dotlr_chg dot1y_chg)
